-
Notifications
You must be signed in to change notification settings - Fork 191
Feature/mongodb atlas memory tool #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Feature/mongodb atlas memory tool #281
Conversation
- Implement mongodb_memory.py following elasticsearch_memory.py patterns - Add MongoDB Atlas vector search with Amazon Bedrock Titan v2 embeddings - Support all CRUD operations: record, retrieve, list, get, delete - Include namespace-based data isolation and pagination - Add comprehensive unit tests (27 tests) with full coverage - Update pyproject.toml with pymongo optional dependency - Graceful error handling for vector index creation - Production-ready with proper logging and validation
- Implement mongodb_memory.py following elasticsearch_memory.py design patterns - Add MongoDB Atlas Vector Search with aggregation pipeline - Support Amazon Bedrock Titan v2 embeddings (1024 dimensions, cosine similarity) - Include namespace-based data isolation for multi-tenant scenarios - Add pagination support with next_token (skip/limit pattern) - Comprehensive error handling and logging - Add 27 unit tests covering all CRUD operations and edge cases - Create detailed documentation following elasticsearch_memory_tool.md pattern - Update README.md with MongoDB Atlas Memory usage examples - Add environment variables configuration for MongoDB Atlas - Add mongodb_memory optional dependency to pyproject.toml
- Integration test file contains sensitive credentials and should remain local only
src/strands_tools/mongodb_memory.py
Outdated
| skip_count = int(next_token) if next_token else 0 | ||
|
|
||
| # Query for memories in namespace | ||
| cursor = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: does this naming consist with other memory tool?
- Implement complete MongoDB Atlas memory tool with vector search capabilities - Add semantic search using Amazon Bedrock Titan embeddings (1024 dimensions) - Support full CRUD operations: record, retrieve, list, get, delete - Add namespace support for multi-user memory isolation - Include environment variable configuration support - Add security features including connection string masking - Implement JSON response format optimization - Add comprehensive test suite with 27 test cases covering all functionality - Follow same design principles as existing Elasticsearch memory tool
|
@JackYPCOnline , @cagataycali Addressed all the feedback in the latest commit |
src/strands_tools/mongodb_memory.py
Outdated
| ) | ||
| # Create agent with secure tool usage | ||
| agent = Agent(tools=[memory_tool.mongodb_memory]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be : mongodb_memory
src/strands_tools/mongodb_memory.py
Outdated
| from strands_tools.mongodb_memory import MongoDBMemoryTool | ||
| # RECOMMENDED: Secure class-based approach (credentials hidden from agents) | ||
| memory_tool = MongoDBMemoryTool( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is different from doc. Please keep all docs consitent.
- Fix documentation examples to use consistent class-based approach - Remove unnecessary query parameters from connection string examples - Add comprehensive MongoDB Atlas connection URI guidance - Add explanatory code comments for numCandidates usage - Ensure all examples follow the same pattern throughout documentation - All 27 unit tests continue to pass - Tested with real MongoDB Atlas credentials successfully
|
@JackYPCOnline Addressed the latest feedback |
- Resolve conflicts in README.md by merging MongoDB Atlas Memory Tool and Retrieve Tool sections - Resolve conflicts in pyproject.toml by including both elasticsearch_memory and mongodb_memory dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please review all files thoroughly to ensure code quality
…MongoDB connection strings - Remove ?retryWrites=true&w=majority from all MongoDB connection string examples in README.md - Clean up connection string format to follow best practices - Addresses review comment about unnecessary query parameters
|
@JackYPCOnline Addressed latest feedback |
- Increased MAX_RESPONSE_SIZE from 1,000 to 70,000 characters - Increased MAX_CONTENT_LENGTH from 8,000 to 12,000 characters - Increased MAX_MEMORIES_IN_RESPONSE from 2 to 5 memories - Fixed unit tests to correctly access JSON from response content - All 27 unit tests now passing
|
@JackYPCOnline @cagataycali Addressed the latest comments |
…amples - Fix incorrect tool reference in usage example (line 89) - Simplify module docstring examples to match documentation pattern - Fix linter error: split long error message for line length compliance - All tests passing (1077 passed) - Formatter and linter checks passing
Description
This PR adds a comprehensive MongoDB Atlas Memory tool that provides semantic memory management capabilities using MongoDB Atlas as the backend with vector embeddings for semantic search.
Key Features:
Implementation Details:
$vectorSearchaggregation pipelineRelated Issues
Documentation PR
Type of Change
New Tool
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
I ran
hatch run prepareAll 27 unit tests pass successfully
Integration tests with real MongoDB Atlas cluster verified functionality
Code formatting and linting checks pass
No breaking changes to existing functionality
Test Coverage:
Checklist
I have read the CONTRIBUTING document
I have added any necessary tests that prove my fix is effective or my feature works
I have updated the documentation accordingly
I have added an appropriate example to the documentation to outline the feature
My changes generate no new warnings
Any dependent changes have been merged and published
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.